const app = getApp();
const common = require('../../utils/common.js');
const api = require('../../config/api.js');

var WxParse = require('../../lib/wxParse/wxParse.js');

Page({

  data: {
    imgUrl: app.globalData.imgurl
  },
  onLoad: function (options) {
    this.setData({
      articleId: options.articleId
    });
  },
  onShow: function () {
    this.getArticleDetail();
  },
  getArticleDetail: function () {
    let that = this;
    let data = {
      articleId: that.data.articleId
    }
    common.request(api.ArticleDetail, data, 'post').then(function (data) {
      if (data.type === 'success') {
        that.setData({
          title: data.data.title,
          subTitle: data.data.subTitle,
          showImageUrl: data.data.showImageUrl,
          hits: data.data.hits,
					linkProductCategoryId: data.data.linkProductCategoryId
        });
        WxParse.wxParse('content', 'html', data.data.content, that, 0);
      }
    });
  },
  onShareAppMessage: function () {
    var articleId = this.data.articleId;
    return {
      title: 'NideShop',
      desc: '瓯客会',
      path: '/pages/newsDetail/newsDetail?articleId=' + articleId
    }
  }
})